package com.ccp.dev.qbdms.service;

import com.ccp.dev.core.basic.base.BaseService;
import com.ccp.dev.core.basic.web.query.QueryFilter;
import com.ccp.dev.core.util.DateFormatUtil;
import com.ccp.dev.core.util.StringUtil;
import com.ccp.dev.qbdms.dao.WQbdProductCertificateInfoDao;
import com.ccp.dev.qbdms.model.WQbdProductCertificateInfo;
import com.ccp.dev.qbdms.util.NumUtils;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * w_qbd_product_certificate_info 信息操作服务类
 *
 * @author milihao
 * @date 2020-10-19 15:36:00
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class WQbdProductCertificateInfoService extends BaseService<WQbdProductCertificateInfo> {

	@Resource
	private WQbdProductCertificateInfoDao dao;

	/**
	 * 导出用查询
	 *
	 * @param queryFilter 查询参数
	 * @return list
	 */
	public List<WQbdProductCertificateInfo> queryAll(QueryFilter queryFilter) {
		return dao.queryAll(queryFilter);
	}

	/**
	 * 获取新的注册编号
	 * @return
	 */
	public String generateNewRegisternum() {
		String maxRegisternum = dao.getMaxRegisternum();
		String newRegisternum="";
		String nowYearMonth = DateFormatUtil.getNowByString("yyyyMMdd");
		if (StringUtil.isNotEmpty(maxRegisternum)) {
			String pre = maxRegisternum.substring(0,Math.min(maxRegisternum.length(),8));
			if (!pre.equals(nowYearMonth)) {
				newRegisternum = nowYearMonth + "001";
			} else {
				String max = maxRegisternum.substring(8,maxRegisternum.length());
				newRegisternum = NumUtils.getNum(maxRegisternum, max);
			}
		} else {
			newRegisternum = nowYearMonth + "001";
		}
		return newRegisternum;
	}

	/**
	 * 获取新的注册编号
	 * @return
	 */
	public String generateNewRegisternumS(String numb) {
		String newRegisternum="BM-" + numb;
		return newRegisternum;
	}
}
